/*  Beamed (the only limit is your imagination) */
/*  Copyright (C) 2012  Michael F�rst */
/*  */
/*  This program is free software; you can redistribute it and/or modify it */
/*  under the terms of the GNU General Public License as published by the */
/*  Free Software Foundation; either version 3 of the License, or (at your */
/*  option) any later version. */
/*  */
/*  This program is distributed in the hope that it will be useful, but */
/*  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY */
/*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */
/*  for more details. */
/*  */
/*  You should have received a copy of the GNU General Public License along */
/*  with this program; if not, see <http://www.gnu.org/licenses/>. */

var Presentation = new HCP_CPresentation();

function HCP_CPresentation() {
	var that = this;
	var ObjectManager = null;
	var RenderEngine = null;
	this.keyboard_input_state = true;
	this.external_key_handler = null;
	this.mouse_click_listener = null;
	this.bkgGrad = null;
	this.bottombar = true;
	this.debug = true;
	this.mousewheel = true;
	
	this.addObject = function (obj) {
		ObjectManager.addObject(obj);
	};
	this.addPathpoint = function (pathpoint) {
		ObjectManager.addPathpoint(pathpoint);
	};
	this.removeObject = function (obj) {
		ObjectManager.removeObject(obj);
	};
	this.removePathpoint = function (pathpoint) {
		ObjectManager.removePathpoint(pathpoint);
	};
	this.start = function(fullscreen, width, height, container) {
		/* check if dependencies are already existing */
		if (ObjectManager == null && RenderEngine == null) {
			ObjectManager = new HCP_CObjectManager();
			RenderEngine = new HCP_CRenderEngine();
		} else {
			return false; /* an error occured, there is already running a presentation */
		}
		// load the presentation
		that.B_Callback();

		/* init the RenderEngine */
		var canvas = RenderEngine.init(fullscreen, width, height, container);
		/* init the ObjectManager, needs canvas for MouseHandlers */
		ObjectManager.init(canvas);
		/*
		 * let's start the infinite loop, but let him know where his render
		 * engine is
		 */
		ObjectManager.launch(RenderEngine);
		return true;
	};

	this.stop = function() {
		/* stop the loop */
		if (ObjectManager != null)
			ObjectManager.stop();
		/* set all local references to null */
		ObjectManager = null;
		RenderEngine = null;
		/* let the garbage collector do it's job */
	};
	this.getStepsCount = function () {
		return ObjectManager.getStepsCount();
	};
	this.B_Callback = function () {
		Presentation.addObject(new CObject(B_Obj_Text, {x:0,y:0,size:50,str:"No valid presentation found!"}, null, -1, -1));
	};
}
